package com.user.service;


import com.user.dao.UserDao;
import com.user.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserDao userDao;

    //增加用户
    @Override
    public void addUser(User user) {
        System.out.println(user.getName()+user.getPassword());
        userDao.addUser(user);
    }
    //删除用户
    @Override
    public void deleteUser(int id) {
        userDao.deleteUser(id);
    }
    //按id查找用户
    @Override
    public User loadUser(int uid) {
        return userDao.loadUser(uid);
    }

    @Override
    public User loadUser(String uname) {
        return userDao.loadUser(uname);
    }

    //更新修改用户
    @Override
    public void update(User user) {
        userDao.update(user);
    }
    //查找所有用户
    @Override
    public List<User> list() {
        return userDao.list();
    }
    //用户登录
    @Override
    public User login(String uname, String uPwd) {
        return userDao.login(uname,uPwd);
    }
    //是否已经存在该用户
    @Override
    public boolean isExist(String uname) {
        return userDao.isExist(uname);
    }
}
